﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using Business;
using Global.Util;
using Models;

namespace RestaurentReviewWeb.Admin
{
    public partial class RestaurentManager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                PopulateRestaurentList();
            }
        }

        private void PopulateRestaurentList()
        {
            var restaurentLogic = new RestaurentLogic();
            List<Restaurent> restaurents = restaurentLogic.GetRestaurents();

            gridRestaurant.DataSource = restaurents;

            gridRestaurant.DataBind();

            //string htmString = XslTransformer.Instance.TransformToHtml(restaurents, CommonConstants.XSL_FILE_RESTAURENT_ADMIN_VIEW);
        }

        protected void EditRestaurent(object sender, GridViewEditEventArgs e)
        {
            Response.Redirect("EditCreate.aspx?mode=edit&id="+e.NewEditIndex);
        }

        protected void AddNewRestaurant(object sender, EventArgs e)
        {
            Response.Redirect("EditCreate.aspx");
        }
    }
}